class DltsCustomPlugin {
  apply(compiler) {
    compiler.hooks.afterCompile.tap("MyCustomPlugin", (compilation) => {
      // 获取输出资源列表
      const assets = compilation.assets;
      for (const filename in assets) {
        if (assets.hasOwnProperty(filename)) {
          console.log("输出资源:", filename);
        }
      }

      console.log("modules total", compilation.modules.length);
      const modules = compilation.modules;
      for (const file of modules) {
        if (file.resource?.includes('setup=true')) {
          console.log("==========>");
          console.log(file.resource);
          // console.log(file._source._value);
        }
      }

      // chunk-vendors + app + 路由 import 数
      console.log("chunks total", compilation.chunks.length);
    });
  }
}

module.exports = DltsCustomPlugin;
